package api.txReward;

import android.content.Context;

import java.lang.ref.SoftReference;

/**
 * 广点通激励视频
 */
public abstract class Reward_API_TX {

    public static String clazz = "api.txReward.TX_Reward";

    private static SoftReference<Reward_API_TX> sf;

    public synchronized static Reward_API_TX getInstance() {

        if (sf == null || sf.get() == null) {
            Object o = null;
            try {
                o = Class.forName(clazz).newInstance();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            if (o != null) {
                sf = new SoftReference<>((Reward_API_TX) o);
                return (Reward_API_TX) o;
            }
        }
        return sf == null ? null : sf.get();
    }

    /**
     * @param context      Activity
     * @param appid        程序id
     * @param adposid      广告id
     * @param listener
     */
    public abstract void LoadTXReward(Context context, String appid, String adposid, final TXRewardListener listener);

    public interface TXRewardListener {
        void onExpose();

        void onClick();

        void onVideoCached();

        void onReward();

        void onClose();

        void onLoad();

        void onVideoComplete();

        void onError(int code, String msg);

        void onShow();
    }
}